package cn.com.controler.Vipapplication;

import cn.com.entity.Vipapplication;

import java.util.List;

public class VipapplicationDAO {

    //添加
    public int addVipSq(Vipapplication vipapplication){
        String str = "insert into vipapplication values(null,?,?,?,?,?,?,?,?,0)";
        Object[] arr = new Object[]{vipapplication.getAppVipId(),vipapplication.getUsername(),vipapplication.getUserpassword(),vipapplication.getUserEmail(),vipapplication.getVipUserRegisterTime(),vipapplication.getVipUserAppStartTime(),vipapplication.getVipUserAppEndTime(),vipapplication.getVipUserAppWhy()};
        return VipapplicationDAOTemplete.insertdata(str,arr);
    }
    //按姓名查询和状态
    public List<Vipapplication> allnamee(String username){
        String str = "select * from vipapplication where Username = ? order by VipUserAppState asc";
        Object[]arr = new Object[]{username};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
    //按姓名查询和状态
    public List<Vipapplication> allname(String username){
        String str = "select * from vipapplication where Username = ? and VipUserAppState !=2";
        Object[]arr = new Object[]{username};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
    //按姓名和状态查询
    public List<Vipapplication> senamestate(String username){
        String str = "select * from vipapplication where Username = ? and VipUserAppState = 1";
        Object[]arr = new Object[]{username};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
    //管理员通过申请
    public int agreeapp(int id){
        String str = "update vipapplication set VipUserAppState = 1 where VipId=?";
        Object[] arr = new Object[]{id};
        return VipapplicationDAOTemplete.insertdata(str,arr);
    }

    //管理员通过申请
    public int refuseapp(int id){
        String str = "update vipapplication set VipUserAppState = 2 where VipId=?";
        Object[] arr = new Object[]{id};
        return VipapplicationDAOTemplete.insertdata(str,arr);
    }


    //查询全部
    public List<Vipapplication> allsq(){
        String str = "select * from vipapplication";
        Object[]arr = new Object[]{};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }

    //查询全部未处理
    public List<Vipapplication> allsqwcl(){
        String str = "select * from vipapplication where VipUserAppState = 0";
        Object[]arr = new Object[]{};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
    //查询全部已通过
    public List<Vipapplication> allsqycl(){
        String str = "select * from vipapplication where VipUserAppState = 1";
        Object[]arr = new Object[]{};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
    //查询全部已打回
    public List<Vipapplication> allsqydh(){
        String str = "select * from vipapplication where VipUserAppState = 2";
        Object[]arr = new Object[]{};
        return VipapplicationDAOTemplete.selectdata(str,arr);
    }
}
